﻿using PlayerRoles;
using PluginAPI.Core.Attributes;
using PluginAPI.Enums;
using PluginAPI.Events;
using RoleCustom.Main;
using Utils;


namespace RoleCustom.Event
{
    public class SCP049Event
    {
        [PluginEvent(ServerEventType.PlayerSpawn)]
        public void OnPlayerSpawn(PlayerSpawnEvent ev)
        {
            if (ev.Player.Role != RoleTypeId.Scp049) return;

            TimeCoroutine.Delay(0.5f, () =>
            {
                PlayerUtils.SetHP(ev.Player,
                    CodeLoad.Singleton.Config.SCP049Event.Health,
                    CodeLoad.Singleton.Config.SCP049Event.Health);

                PlayerUtils.SetAP(ev.Player,
                    CodeLoad.Singleton.Config.SCP049Event.AHealth,
                    CodeLoad.Singleton.Config.SCP049Event.AHealth);
            });
        }

        [PluginEvent(ServerEventType.PlayerDamage)]
        public void OnPlayerDamage(PlayerDamageEvent ev)
        {
            if (ev == null) return;
            if (ev.Player == null) return;
            if (ev.Player.Role != RoleTypeId.Scp049) return;

            try
            {
                if (ev.Target == null) return;

                ev.Target.Health = 1;
            }
            catch
            { 
                
            }
        }
    }
}
